Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call controller methods directly in send duck #14465

Merged
merged 6 commits into from
Apr 26, 2022

Conversation

brad-decker
Copy link
Contributor

@brad-decker brad-decker commented Apr 18, 2022

Explanation

There is no need for us to call provider methods in our send duck to create transactions, we already generate the txParams.data for transactions but strip it from the call to these provider methods so that the provider methods generate them for us. However the logic we use for generating the txParams.data in the send duck is the same as the logic these methods invoke.

This change will allow us to get a handle on the created transactionMeta and update it when necessary. We don't do that yet, but in a future PR I will add additional logging to the transaction history to show the steps that a user took to create the transaction. This will help us further debug transactions that are flagged in support tickets.

Manual testing steps

  1. Test whether sending ETH/native asset works appropriately
  2. Test whether sending ERC20s work appropriately
  3. Test whether sending NFTs work appropriately

@brad-decker brad-decker force-pushed the use-controller-methods-to-create-transactions branch 2 times, most recently from 13d23c0 to 10cfc1e Compare April 19, 2022 14:40
@brad-decker brad-decker marked this pull request as ready for review April 19, 2022 15:10
@brad-decker brad-decker requested a review from a team as a code owner April 19, 2022 15:10
@brad-decker brad-decker requested review from Gtonizuka and dan437 April 19, 2022 15:10
@metamaskbot
Copy link
Collaborator

Builds ready [10cfc1e]
Page Load Metrics (1306 ± 32 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint78140101157
domContentLoaded1208138412784823
load1211145913066832
domInteractive1207138412784823

highlights:

storybook

SWAP_TRANSACTION_TYPES.includes(transactionType) ||
transactionType === TRANSACTION_TYPES.SIMPLE_SEND ||
transactionType === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER ||
transactionType === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be more readable if we create a var to hold all of these cases?

var VALID_TRANSACTION_TYPES = [
  ...SWAP_TRANSACTION_TYPES,
  TRANSACTION_TYPES.SIMPLE_SEND,
// ....
]

........
!(VALID_TRANSACTION_TYPES.includes(transactionType))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REsolved in latest

digiwand
digiwand previously approved these changes Apr 20, 2022
Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 Nice cleanup

txParams,
origin,
'metamask',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Are we certain origin can't be another value? I'm unfamiliar with where the origin(s) of origin are.

The other thing I'm wondering is if it would help to turn this into a constant value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good to use a constant. Origin is always the dapp that suggests the transaction. Because this method will only be called from within MetaMask the transaction will always originate from metamask.

@brad-decker brad-decker force-pushed the use-controller-methods-to-create-transactions branch from ba889b0 to 3ad0233 Compare April 21, 2022 15:13
@brad-decker
Copy link
Contributor Author

@digiwand used the constant for origin. Thanks. @darkwing can I get a re-review

@metamaskbot
Copy link
Collaborator

Builds ready [d41495c]
Page Load Metrics (1439 ± 91 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint791599187325156
domContentLoaded11991711141317383
load11991818143919091
domInteractive11991711141317383

highlights:

storybook

Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me and I was able to send a native ETH and ERC-20!

Copy link
Contributor

@segun segun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brad-decker brad-decker merged commit 193c225 into develop Apr 26, 2022
@brad-decker brad-decker deleted the use-controller-methods-to-create-transactions branch April 26, 2022 17:07
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants